package pers.kw.feign.fallback;

import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import pers.kw.feign.FileApiService;
import pers.kw.file.dto.FileDto;
import pers.kw.protocol.R;

import javax.servlet.http.HttpServletResponse;

@Component
public class FileServerFallbackFactory implements FallbackFactory<FileApiService> {

    private static final Logger log = LoggerFactory.getLogger(FileServerFallbackFactory.class);

    @Override
    public FileApiService create(Throwable throwable) {
        log.error("FileServer调用异常:", throwable);
        return new FileApiService() {

            @Override
            public R<String> uploadFile(MultipartFile file) throws Exception {
                return null;
            }

            @Override
            public void downloadFile(HttpServletResponse httpServletResponse, String fileName) throws Exception {

            }

            @Override
            public R<String> getFileExpiryAccessUrl(String file) throws Exception {
                return null;
            }
        };
    }
}
